package controller;

import controller.dialog.DialogPopUpMenu;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import model.TAGS;
import rmi.RMIServer;

/**
 * FXML Controller class
 * 
 * @author Adriano
 */
public class PopupMenuController implements Initializable {

    @FXML
    private Label message;
    @FXML
    private Label id;
    @FXML
    private TextField valor;
    @FXML
    private Label label;

    @Override
    public void initialize(URL url, ResourceBundle rb) {
    }

    public void ofertar(ActionEvent event) {
        label.setText("");
        try {
            double v = Double.parseDouble(valor.getText().trim());
            if (v > 0) {
                RMIServer.getInstacia().getJogadas().ofertaCompra(TAGS.NAME, Integer.parseInt(id.getText()), v);
                DialogPopUpMenu.getIntancia().close();
            } else {
                label.setText("Oferta Inválida");
            }
        } catch (Exception e) {
            label.setText("Oferta Inválida");
        }
    }
    
    public void sair(ActionEvent event){
        DialogPopUpMenu.getIntancia().close();
        label.setText("");
    }
}
